-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add 5s and 10s average of ampere to help calibrate ampere sensor. #4655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Auto-closing pull request because the source branch is named 'master'. Please create a feature branch instead. https://betaflight.com/docs/development#using-git-and-github |
|
Caution Review failedThe pull request is closed. WalkthroughAdds 5s/10s amperage average tracking and display for Motors and Power tabs. Introduces history buffers and average calculations in JS, new DOM elements in HTML, and corresponding i18n strings for en and zh_CN locales. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Poller as Data Poller
participant MotorsJS as motors.js
participant DOM as Motors DOM
Poller->>MotorsJS: New amperage reading
MotorsJS->>MotorsJS: Push to 5s/10s histories (trim to sizes)
MotorsJS->>MotorsJS: Compute 5s and 10s averages
MotorsJS->>DOM: Update .motors-bat-amperage-average-5s
MotorsJS->>DOM: Update .motors-bat-amperage-average-10s
note right of DOM: Uses i18n: motorsAmperageAverage5s/10s and value format keys
sequenceDiagram
autonumber
participant SlowTick as Slow Update Tick
participant PowerJS as power.js
participant DOM as Power DOM
SlowTick->>PowerJS: Read current amperage
PowerJS->>PowerJS: Update 5s/10s histories (trim)
PowerJS->>PowerJS: Calculate 5s/10s averages
PowerJS->>DOM: Set #amperage-average-5s value
PowerJS->>DOM: Set #amperage-average-10s value
note right of DOM: Labels via powerBatteryAmperageAverage5s/10s
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds 5-second and 10-second rolling averages for amperage readings to help with calibrating ampere sensors. The feature provides more stable readings by smoothing out short-term fluctuations.
- Adds amperage averaging functionality to both power and motors tabs
- Implements rolling window calculations with configurable history sizes
- Updates UI to display the new average values alongside existing amperage readings
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tabs/power.html | Adds HTML table rows for displaying 5s and 10s amperage averages |
| src/tabs/motors.html | Adds HTML spans for displaying 5s and 10s amperage averages |
| src/js/tabs/power.js | Implements rolling average calculation logic for power tab |
| src/js/tabs/motors.js | Implements rolling average calculation logic for motors tab |
| locales/zh_CN/messages.json | Adds Chinese translations for new amperage average labels |
| locales/en/messages.json | Adds English translations for new amperage average labels |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| amperageHistory5s: [], // Store last 5 seconds of amperage readings for average calculation | ||
| amperageHistorySize5s: 25, // Number of readings to keep for 5 seconds average (5Hz * 5s = 25) | ||
| amperageHistory10s: [], // Store last 10 seconds of amperage readings for average calculation | ||
| amperageHistorySize10s: 50, // Number of readings to keep for 10 seconds average (5Hz * 10s = 50) |
Copilot
AI
Oct 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment indicates 5Hz update rate but this assumption should be verified. If the actual update rate differs from 5Hz, the averaging windows will be incorrect. Consider making the update rate configurable or detecting it dynamically.
| amperageHistory5s: [], // Store last 5 seconds of amperage readings for average calculation | |
| amperageHistorySize5s: 25, // Number of readings to keep for 5 seconds average (5Hz * 5s = 25) | |
| amperageHistory10s: [], // Store last 10 seconds of amperage readings for average calculation | |
| amperageHistorySize10s: 50, // Number of readings to keep for 10 seconds average (5Hz * 10s = 50) | |
| amperageUpdateRateHz: 5, // Default update rate in Hz; change if actual rate differs | |
| amperageHistory5s: [], // Store last 5 seconds of amperage readings for average calculation | |
| get amperageHistorySize5s() { return this.amperageUpdateRateHz * 5; }, // Number of readings for 5s average | |
| amperageHistory10s: [], // Store last 10 seconds of amperage readings for average calculation | |
| get amperageHistorySize10s() { return this.amperageUpdateRateHz * 10; }, // Number of readings for 10s average |
| sensorAccelRate: 20, | ||
| sensorAccelScale: 2, | ||
| amperageHistory5s: [], // Store last 5 seconds of amperage readings for average calculation | ||
| amperageHistorySize5s: 20, // Number of readings to keep for 5 seconds average (4Hz * 5s = 20) |
Copilot
AI
Oct 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motors tab uses a different update rate assumption (4Hz) than the power tab (5Hz). This inconsistency could lead to different averaging behavior between tabs. The update rates should be standardized or made configurable.
|
|
Preview URL: https://pr4655.betaflight-app-preview.pages.dev |



Add 5s and 10s average of ampere to help calibrate ampere sensor.
Summary by CodeRabbit
New Features
Localization